import Vue from 'vue'
import VueRouter from 'vue-router'
import approvalProcess from './modules/approvalProcess'  //审批流程
import powerManage from './modules/powerManage'  //权限管理
import navData from '@/common/navData'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',  //登录页
    name: 'login',
    component: () => import('../views/Login/index.vue')
  },
  {
    path: '/home',  //首页
    name: 'home',
    redirect:'/index',
    meta:{title:"企业首页"},
    component: () => import('../layout/index.vue'),
    children:[
      {
        path: '/index',  //企业首页
        name: 'index',
        meta:{title:"企业首页"},
        component: () => import('../views/Home/index/index.vue')
      },
      {
        path: '/approvalApply',  //申请类别
        name: 'approvalApply',
        meta:{title:"申请类别"},
        component: () => import('../views/Home/approvalApply/index.vue'),
        children:[
          {
            path: 'officeApply',  //办公审批
            name: 'officeApply',
            meta:{title:"办公审批"},
            component: () => import('../views/Home/approvalApply/officeApply.vue')
          },
          {
            path: 'travelApply',  //差旅审批
            name: 'travelApply',
            meta:{title:"差旅审批"},
            component: () => import('../views/Home/approvalApply/travelApply.vue')
          },
          {
            path: 'leaveApply',  //请假审批
            name: 'leaveApply',
            meta:{title:"请假审批"},
            component: () => import('../views/Home/approvalApply/leaveApply.vue')
          }
        ]
      },
      {
        path: '/approvalManage',  //申请管理
        name: 'approvalManage',
        meta:{title:"申请管理"},
        component: () => import('../views/Home/approvalManage/index.vue'),
        children:[
          {
            path: 'officeManage',  //办公审批
            name: 'officeManage',
            meta:{title:"办公审批"},
            component: () => import('../views/Home/approvalManage/officeManage.vue')
          },
          {
            path: 'travelManage',  //差旅审批
            name: 'travelManage',
            meta:{title:"差旅审批"},
            component: () => import('../views/Home/approvalManage/travelManage.vue')
          },
          {
            path: 'leaveManage',  //请假审批
            name: 'leaveManage',
            meta:{title:"请假审批"},
            component: () => import('../views/Home/approvalManage/leaveManage.vue')
          }
        ]
      },
      {
        path: '/fileManage',  //档案管理
        name: 'fileManage',
        meta:{title:"档案管理"},
        component: () => import('../views/Home/fileManage/index.vue')
      },
      approvalProcess,  //审批流程
      powerManage, //权限管理
    ]
  },
]

//常规配置
export const defaultRoutes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',  //登录页
    name: 'login',
    component: () => import('../views/Login/index.vue')
  },
  {
    path: '/home',  //首页
    name: 'home',
    redirect:'/index',
    meta:{title:"企业首页"},
    component: () => import('../layout/index.vue'),
    children:[{
      path: '/index',  //企业首页
      name: 'index',
      meta:{title:"企业首页"},
      component: () => import('../views/Home/index/index.vue')
    }]
  }]

//动态配置
export const asyncRoutes = [  //动态配置
  {
    path: '/index',  //企业首页
    name: 'index',
    meta:{title:"企业首页",roles:['input','approve']},
    component: () => import('../views/Home/index/index.vue')
  },
  {
    path: '/approvalApply',  //申请类别
    name: 'approvalApply',
    meta:{title:"申请类别" ,roles:['input']},
    component: () => import('../views/Home/approvalApply/index.vue'),
    children:[
      {
        path: 'officeApply',  //办公审批
        name: 'officeApply',
        meta:{title:"办公审批"},
        component: () => import('../views/Home/approvalApply/officeApply.vue')
      },
      {
        path: 'travelApply',  //差旅审批
        name: 'travelApply',
        meta:{title:"差旅审批"},
        component: () => import('../views/Home/approvalApply/travelApply.vue')
      },
      {
        path: 'leaveApply',  //请假审批
        name: 'leaveApply',
        meta:{title:"请假审批"},
        component: () => import('../views/Home/approvalApply/leaveApply.vue')
      }
    ]
  },
  {
    path: '/approvalManage',  //申请管理
    name: 'approvalManage',
    meta:{title:"申请管理",roles:['input', 'approve']},
    component: () => import('../views/Home/approvalManage/index.vue'),
    children:[
      {
        path: 'officeManage',  //办公审批
        name: 'officeManage',
        meta:{title:"办公审批"},
        component: () => import('../views/Home/approvalManage/officeManage.vue')
      },
      {
        path: 'travelManage',  //差旅审批
        name: 'travelManage',
        meta:{title:"差旅审批"},
        component: () => import('../views/Home/approvalManage/travelManage.vue')
      },
      {
        path: 'leaveManage',  //请假审批
        name: 'leaveManage',
        meta:{title:"请假审批"},
        component: () => import('../views/Home/approvalManage/leaveManage.vue')
      }
    ]
  },
  {
    path: '/fileManage',  //档案管理
    name: 'fileManage',
    meta:{title:"档案管理",roles:['input']},
    component: () => import('../views/Home/fileManage/index.vue')
  },
  approvalProcess,  //审批流程
  powerManage, //权限管理
]



const router = new VueRouter({
  routes:defaultRoutes
})

export default router
